<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('消息列列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 120px;">标题：</label>
                                <input type="text" name="title"/>
                            </li>
                            <li>
                                <label style="width: 120px;">消息类型：</label>
                                <select name="type">
                                    <option value="" name="type">所有</option>
                                    <option value="1" name="type">服务商消息</option>
                                    <option value="2" name="type">商户消息</option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 120px;">类型：</label>
                                <select name="status">
                                    <option value="" name="status">所有</option>
                                    <option value="1" name="status">系统消息</option>
                                    <option value="2" name="status">小喇叭消息</option>
                                    <option value="3" name="status">常见问题</option>
                                    <option value="4" name="status">活动消息</option>
                                    <option value="5" name="status">奖励消息</option>
                                    <option value="6" name="status">公告消息</option>
                                    <option value="7" name="status">订单消息</option>
                                    <option value="8" name="status">机具消息</option>
                                    <option value="9" name="status">雏鹰入口</option>
                                    <option value="10" name="status">雏鹰详情</option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 120px;">限制档位：</label>
                                <select name="grade">
                                    <option value="">所有</option>
                                    <option value="V1" >V1</option>
                                    <option value="V2" >V2</option>
                                    <option value="V3" >V3</option>
                                    <option value="V4" >V4</option>
                                    <option value="V5" >V5</option>
                                    <option value="V6" >V6</option>
                                    <option value="V7" >V7</option>
                                    <option value="V8" >V8</option>
                                    <option value="V9" >V9</option>
                                    <option value="V10" >V10</option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 120px;">推送消息：</label>
                                <select name="jgStatus">
                                    <option value="">所有</option>
                                    <option value="0" name="jgStatus">未推送</option>
                                    <option value="1" name="jgStatus">已推送</option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label style="width: 120px;">添加日期：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始日期" name="params[beginAddTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束日期" name="params[endAddTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:message:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:message:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:message:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:message:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:message:remove')}]];
        var prefix = ctx + "message/message";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "消息列",
                clickToSelect:true,
                columns: [{
                    radio: true
                },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'goodsId',
                    title: '商品编号'
                },
                {
                    field: 'title',
                    title: '标题',
                    formatter:function (value, row, index) {
                        return $.table.tooltip(value,5);
                    }
                },
                {
                    field: 'content',
                    title: '消息内容',
                    formatter:function (value, row, index) {
                        return $.table.tooltip(value,5);
                    }
                },

                {
                    field: 'addName',
                    title: '添加人'
                },
                {
                    field: 'create_time',
                    title: '添加日期'
                },
                {
                    field: 'type',
                    title: '消息类型',
                    formatter: function (value, row, index) {
                        if (row.type == 1 ){
                            return '<span style="color: green">服务商消息</span>';
                        } else if(row.type == 2 ){
                            return '<span style="color: blue">商户消息</span>';
                        } else {
                            return '<span style="color: red">未知</span>';
                        }
                    }
                },
                {
                    field: 'status',
                    title: '类型',
                    formatter: function (value, row, index) {
                        if (row.status == 1 ){
                            return '<span style="color: green">系统消息</span>';
                        } else if(row.status == 2 ){
                            return '<span style="color: blue">小喇叭消息</span>';
                        } else if(row.status == 3){
                            return '<span style="color: royalblue">常见问题</span>';
                        } else if(row.status == 4 ){
                            return '<span style="color: purple">活动消息</span>';
                        } else if(row.status == 5 ){
                            return '<span style="color: rebeccapurple">奖励消息</span>';
                        } else if(row.status == 6 ){
                            return '<span style="color: red">公告消息</span>';
                        } else if(row.status == 7 ){
                            return '<span style="color: orange">订单消息</span>';
                        } else if(row.status == 8 ){
                            return '<span style="color: orange">机具消息</span>';
                        } else if(row.status == 9 ){
                            return '<span style="color: orange">雏鹰入口</span>';
                        } else if(row.status == 10 ){
                            return '<span style="color: orange">雏鹰详情</span>';
                        } else {
                            return '<span style="color: red">未知</span>';
                        }

                    }
                },
                {
                    field: 'jgStatus',
                    title: '推送状态（极光推送）',
                    formatter: function (value, row, index) {
                        if (row.jgStatus == 0 ){
                            return '<span style="color: red">未推送</span>';
                        } else if(row.jgStatus == 1 ){
                            return '<span style="color: green">已推送</span>';
                        } else {
                            return '<span style="color: red">未知</span>';
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>